//package com.zmn.mcc.admin.controller.test;
//
//import com.zmn.common.dictionary.GlobalDict;
//import com.zmn.common.dto2.ResponseDTO;
//import com.zmn.common.utils.string.StringUtil;
//import com.zmn.cube.common.dro.menu.MenuDRO;
//import com.zmn.cube.dubbo.interfaces.menu.MenuListRemoteService;
//import com.zmn.mcc.business.interfaces.organize.OrganizeBService;
//import com.zmn.mcc.business.interfaces.staff.StaffBService;
//import com.zmn.mcc.business.interfaces.staff.StaffLoginBService;
//import com.zmn.mcc.cache.*;
//import com.zmn.mcc.cas.model.LoginStaff;
//import com.zmn.mcc.cas.web.AbstractAdminController;
//import com.zmn.mcc.common.constant.DpermitConsts;
//import com.zmn.mcc.common.dto.cc.CCStaffDpermitDRO;
//import com.zmn.mcc.common.dto.permit.SpermitDTO;
//import com.zmn.mcc.common.dto.staff.LoginStaffDO;
//import com.zmn.mcc.dubbo.dto.DubboConsts;
//import com.zmn.mcc.dubbo.interfaces.staff.StaffListRemoteService;
//import com.zmn.mcc.dubbo.interfaces.staff.StaffLoginRemoteService;
//import com.zmn.mcc.dubbo.interfaces.staff.StaffPermitRemoteService;
//import com.zmn.mcc.model.entity.dpermit.company.BaseCompanyQuery;
//import com.zmn.mcc.permit.mysql.annotation.ZmnDPermit;
//import com.zmn.mcc.permit.mysql.enums.DPermitTypeEnum;
//import com.zmn.mcc.services.interfaces.staff.StaffService;
//import org.apache.dubbo.config.annotation.DubboReference;
//import org.apache.ibatis.annotations.Param;
//import org.springframework.stereotype.Controller;
//import org.springframework.ui.Model;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.ResponseBody;
//
//import javax.annotation.Resource;
//import javax.servlet.http.HttpServletRequest;
//import java.util.List;
//
///**
// * 员工权限测试
// *
// * @author heguanghua
// * @since 2020/06/04 09:58
// */
//@Controller
//@RequestMapping("/test/")
//public class DpermitTestController extends AbstractAdminController {
//
//    @Resource
//    private StaffService staffService;
//    @Resource
//    private OrganizeBService organizeBService;
//    @Resource
//    private StaffBService staffBService;
//    @Resource
//    private StaffLoginBService staffLoginBService;
//    @DubboReference(version = DubboConsts.INTERFACE_VERSION, check = false)
//    private StaffListRemoteService staffListRemoteService;
//    @DubboReference(version = DubboConsts.INTERFACE_VERSION, check = false)
//    private StaffPermitRemoteService staffPermitRemoteService;
//    @DubboReference(version = DubboConsts.INTERFACE_VERSION, check = false)
//    private StaffLoginRemoteService staffLoginRemoteService;
//    // @Resource
//    // private CompanyService companyService;
//    @Resource
//    private OrganizeCache organizeCache;
//    @Resource
//    private DeptCache deptCache;
//    @Resource
//    private AreaCache areaCache;
//    @Resource
//    private ChannelCache channelCache;
//    @Resource
//    private CubeCache cubeCache;
//
//    @com.alibaba.dubbo.config.annotation.Reference(version = com.zmn.cube.dubbo.dto.DubboConsts.INTERFACE_VERSION, check = false)
//    private MenuListRemoteService menuListRemoteService;
//
//    @RequestMapping(value = "checkPermit")
//    @ResponseBody
//    public ResponseDTO permit(Integer staffId, String url) {
//        return staffListRemoteService.checkPermitBySatffIdAndUrl(staffId, url);
//    }
//
//    /**
//     * 功能权限
//     */
//    @RequestMapping(value = "permit")
//    @ResponseBody
//    public SpermitDTO permit(HttpServletRequest request, Model model) {
//
//        ResponseDTO<LoginStaffDO> responseStaff = staffLoginBService.checkLogin("19920000802", "zmn123456", "192.168.1.10");
//        if (!responseStaff.isSuccess()) {
//            return SpermitDTO.fail(responseStaff.getMessage());
//        }
//
//        LoginStaffDO staffToken = responseStaff.getData();
//        SpermitDTO spermitDTO = staffBService.listPermitByLoginStaff(staffToken, 1009);    // mcc
//
//        return spermitDTO;
//    }
//
//    /**
//     * 数据权限
//     */
//    @RequestMapping(value = "dpermit")
//    @ResponseBody
//    public SpermitDTO dpermit(HttpServletRequest request,
//                              @RequestParam(value = "dataType", defaultValue = "100") int dataType,
//                              @RequestParam(value = "clear", defaultValue = "false") boolean clear,
//                              @RequestParam(value = "username", defaultValue = "19920000802") String username,
//                              @RequestParam(value = "password", defaultValue = "zmn123456") String password,
//                              Model model) {
//
//        ResponseDTO<LoginStaffDO> responseStaff = staffLoginBService.checkLogin(username, password, "192.168.98.25");
//        if (!responseStaff.isSuccess()) {
//            return SpermitDTO.fail(responseStaff.getMessage());
//        }
//
//        LoginStaffDO staffToken = responseStaff.getData();
//        SpermitDTO spermitDTO = staffBService.listDpermitByLoginStaff(staffToken, dataType, clear);
//
//        return spermitDTO;
//    }
//
//    /**
//     * 数据权限：模型访问测试
//     */
//    @RequestMapping(value = "testPermitAndDept")
//    @ResponseBody
//    public SpermitDTO testPermitAndDept(HttpServletRequest request, Integer staffId, Integer type, Integer clean) {
//
//        // 一级部门：{"items":[4376],"message":"OK","range":3,"status":200,"success":true}
//        // 二级部门：{"items":[4377,4378],"message":"OK","range":3,"status":200,"success":true}
//        // 三级部门：{"items":[4381,4380],"message":"OK","range":3,"status":200,"success":true}
//        // 省：{"items":[370000,450000,500000,510000],"message":"OK","range":3,"status":200,"success":true}
//        // 市：{"items":[370000,450000,500000,510000],"message":"OK","range":3,"status":200,"success":true}
//        // 区：{"items":[510101,510104,510105,510106,510107,510108,510112,510113,510114,510115,510116],"message":"OK","range":3,"status":200,"success":true}
//        // 下单平台（啄木鸟平台）：{"items":[10],"message":"OK","range":3,"status":200,"success":true}
//        // 下单平台（无：部门_没有配置就是所有）：{"items":[],"message":"OK","range":2,"status":200,"success":true}
//        // 一级渠道：{"items":[32772,32805,31143,32175,32268,32273,32279],"message":"OK","range":3,"status":200,"success":true}
//        // 二级渠道（配置下单平台，无：不表示全部）：{"items":[],"message":"没有取得指定层级的权限列表","range":1,"status":200,"success":true}
//        // 二级渠道（有配置）：{"items":[31098,32838,32806,1478,1444,1443,1445,1524,10131,10659,10708],"message":"OK","range":3,"status":200,"success":true}
//
////        SpermitDTO staff = staffBService.listDpermitByStaffId(141385, DpermitConsts.TYPE_CHANNEL_C2);
//        SpermitDTO staff = staffBService.listDpermitByStaffId(staffId, type, clean == 2 ? true : false);
//
//        if (staff.getStatus() != 200) {
//            return SpermitDTO.fail("无数据权限");
//        }
//
//        List items = staff.getItems();
//
//        System.out.println(items);
//
//        return staff;
//    }
//
//    /**
//     * 数据权限：
//     */
//    @RequestMapping(value = "testDPermit")
//    @ResponseBody
//    @ZmnDPermit(types = {DPermitTypeEnum.ORG_ONE, DPermitTypeEnum.ORG_TWO, DPermitTypeEnum.ORG_THR, DPermitTypeEnum.COMP_SP}, noAccess = false)
////    @ZmnDPermit(types = {DPermitTypeEnum.ORG_ONE, DPermitTypeEnum.ORG_TWO, DPermitTypeEnum.ORG_THR})
//    public SpermitDTO testDPermitAnnotation(HttpServletRequest request) {
//        LoginStaff staff = getLoginStaff();
//
//        BaseCompanyQuery query = new BaseCompanyQuery();
//        //query.setType(888);
//        //query.setPlat(10);
//        query.setOperatorId(141385);
//        query.setStatus(2);
//        //query.setLoginStaffDO(staff);
//
////        List<Integer> listId = new ArrayList<>();
////        listId.add(101);
////        listId.add(102);
////
////
////        List<CompanyTypeQuery> querys = new ArrayList<>();
////        CompanyTypeQuery q1 = new CompanyTypeQuery();
////        q1.setChildType(1001);
////        q1.setType(101);
////        CompanyTypeQuery q2 = new CompanyTypeQuery();
////        q2.setChildType(2001);
////        q2.setType(201);
//
////        querys.add(q1);
////        querys.add(q2);
////
////        query.setCompanyTypeQueryList(querys);
//
//
//        // List<BaseCompany> list = companyService.listByQuery(query);
////        List<BaseCompany> list = companyService.listPageByQuery(query);
////         System.out.println(list);
//
//        return SpermitDTO.success(null);
//    }
//
//
//    /**
//     * 远程调用功能权限
//     */
//    @RequestMapping(value = "dubbo/permit")
//    @ResponseBody
//    public SpermitDTO dubboPermit(HttpServletRequest request, Model model) {
//
//        ResponseDTO<LoginStaffDO> responseStaff = staffLoginRemoteService.checkLogin("19920000802", "zmn123456", "192.168.1.10");
//        if (!responseStaff.isSuccess()) {
//            return SpermitDTO.fail(responseStaff.getMessage());
//        }
//
//        LoginStaffDO staffToken = responseStaff.getData();
//        SpermitDTO spermitDTO = staffPermitRemoteService.listPermitByLoginStaff(staffToken, 1009);    // mcc
//
//        return spermitDTO;
//    }
//
//    /**
//     * 远程调用数据权限
//     */
//    @RequestMapping(value = "dubbo/dpermit")
//    @ResponseBody
//    public SpermitDTO dubboDpermit(HttpServletRequest request, Model model) {
//
//        ResponseDTO<LoginStaffDO> responseStaff = staffLoginRemoteService.checkLogin("19920000802", "zmn123456", "192.168.1.10");
//        if (!responseStaff.isSuccess()) {
//            return SpermitDTO.fail(responseStaff.getMessage());
//        }
//
//        LoginStaffDO staffToken = responseStaff.getData();
//        SpermitDTO spermitDTO = staffPermitRemoteService.listDpermitByLoginStaff(staffToken, DpermitConsts.TYPE_AREA, true);
//        System.out.println("=====" + StringUtil.convertListToStrs(spermitDTO.getItems()));
//
//        return spermitDTO;
//    }
//
//
//    /**
//     * 功能权限
//     */
//    @RequestMapping(value = "menu/cube")
//    @ResponseBody
//    public ResponseDTO<List<MenuDRO>> menu(HttpServletRequest request, Model model) {
//        String level = request.getParameter("level");
//        Integer cubeLevel = DpermitConsts.CUBE_LEVEL_FOUR;
//        if (StringUtil.isNotBlank(level)) {
//            cubeLevel = Integer.parseInt(level);
//        }
//
//        return menuListRemoteService.listAboveByLevel(cubeLevel, GlobalDict.STATUS_ENABLE);
//    }
//
//
//
//}
